package pack1;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class sprg26 {
public static void main(String[] args) throws InterruptedException {
	WebDriver driver=new FirefoxDriver();
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	driver.manage().window().maximize();
	driver.get("http://anand-pc/login.do");
	driver.findElement(By.name("username")).sendKeys("admin");
	driver.findElement(By.name("pwd")).sendKeys("manager");
	driver.findElement(By.id("loginButton")).click();
	Thread.sleep(1000);
	driver.findElement(By.linkText("Tasks")).click();
	driver.findElement(By.xpath("//input[@value='Create New Tasks']")).click();
	WebElement cSelect = driver.findElement(By.name("customerId"));
	
			Select select=new Select(cSelect);
			//for(int i=0;i<select.getOptions().size();i++)
		//	{	System.out.println(select.getOptions().get(i).getText());
			  select.selectByVisibleText("manu.raj37@gmail.com");
			//}
			//select.selectByIndex(1);
			Thread.sleep(1000);
			//driver.findElement(By.name("customerName")).sendKeys("custmr");
			Thread.sleep(1000);
			  
			  select=new Select(driver.findElement(By.name("projectId")));
			  System.out.println("proj selectd");
			  
			  select.selectByIndex(6);
			  Thread.sleep(1000);
			//  driver.findElement(By.name("projectName")).sendKeys("automatic");
			  //Thread.sleep(1000);
			  driver.findElement(By.xpath("//input[@name='task[0].name']")).sendKeys("tstt123");
			  Thread.sleep(1000);
			 //driver.findElement(By.xpath("//input[@id='taskDeadline0']")).sendKeys("Oct 19, 2013");
			  
			   driver.findElement(By.id("ext-gen7")).click();
			  Thread.sleep(1000);
			  driver.findElement(By.xpath("//td[@class='x-date-activex-date-weekend x-date-weekend']//span[text()='26']")).click();
			  
			  Thread.sleep(1000);
			  driver.findElement(By.xpath("//input[@name='task[0].markedToBeAddedToUserTasks']")).click();
			  Thread.sleep(1000);
			  
			  //driver.findElement(By.xpath("//input[@name='task[0].markedToBeAddedToUserTasks']")).click();
			  Thread.sleep(1000);
			  driver.findElement(By.xpath("//input[@value='Create Tasks']")).click();

			  Thread.sleep(1000);
			  
			  driver.findElement(By.linkText("All")).click();
			 // driver.findElement(By.xpath("//input[@name='taskSelected[4]']")).click();
			  Thread.sleep(1000);
			  driver.findElement(By.xpath("//input[@value='Delete Selected Tasks']")).click();
			  driver.findElement(By.id("deleteButton")).click();
}
}
